package com.cw.starter.common.converter;


import com.cw.starter.common.helper.PageInfo;

/**
 * @author chenw
 * @version $$Id: PageInfoConverter.java, v 0.1 2018/11/27 6:17 PM chenw Exp $$
 */
public class PageInfoConverter {

    public static <E> PageInfo<E> convert(com.github.pagehelper.PageInfo<E> pageInfo) {
        if (pageInfo == null) {
            return null;
        }
        PageInfo<E> newPageInfo = new PageInfo<>();
        newPageInfo.setPageNum(pageInfo.getPageNum());
        newPageInfo.setPageSize(pageInfo.getPageSize());
        newPageInfo.setPages(pageInfo.getPages());
        newPageInfo.setSize(pageInfo.getSize());
        newPageInfo.setTotal(pageInfo.getTotal());
        newPageInfo.setStartRow(pageInfo.getStartRow());
        newPageInfo.setEndRow(pageInfo.getEndRow());
        newPageInfo.setPrePage(pageInfo.getPrePage());
        newPageInfo.setNextPage(pageInfo.getNextPage());
        newPageInfo.setFirstPage(pageInfo.isIsFirstPage());
        newPageInfo.setLastPage(pageInfo.isIsLastPage());
        newPageInfo.setHasPreviousPage(pageInfo.isHasPreviousPage());
        newPageInfo.setHasNextPage(pageInfo.isHasNextPage());
        newPageInfo.setNavigatePages(pageInfo.getNavigatePages());
        newPageInfo.setNavigatePageNums(pageInfo.getNavigatepageNums());
        newPageInfo.setNavigateFirstPage(pageInfo.getNavigateFirstPage());
        newPageInfo.setNavigateLastPage(pageInfo.getNavigateLastPage());
        newPageInfo.setList(pageInfo.getList());
        return newPageInfo;
    }
}
